package com.chain.BrotherExchange.ui.listener;

import android.view.KeyEvent;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

/**
 * 响应指定键盘事件
 */
public class OnSpecificEditorActionListener implements OnEditorActionListener {

    private final int mActionId;

    private OnEditorActionListener mOnEditorActionListener;

    /**
     * @param actionId {@link android.view.inputmethod.EditorInfo}
     */
    public OnSpecificEditorActionListener(int actionId, OnEditorActionListener onEditorActionListener) {
        this.mActionId = actionId;
        this.mOnEditorActionListener = onEditorActionListener;
    }

    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (mActionId == actionId) {
            return mOnEditorActionListener.onEditorAction(v, actionId, event);
        }

        return false;
    }
}
